#include <iostream>
#include <cmath>
#include "../inc/Antenna.hxx"
#include "../inc/Utils.hxx"

using namespace std;

Antenna::Antenna() {}

int Antenna::RPM = 5;
int Antenna::PRF = 100;
int Antenna::ROUND_NUMBER = 0;
bool Antenna::IS_NEW_ROUND = false;
double Antenna::AZIMUTH = 0;
double Antenna::ROW_DISTANCE = 0.1;

double Antenna::getRPS() {
    return (double)RPM/60;
}

void Antenna::updateState() {
    double previousAzimuth = AZIMUTH;
    AZIMUTH = fmod(AZIMUTH+getDAzimuth(), 2*M_PI);
    if(fabs(previousAzimuth-AZIMUTH) > 2*getDAzimuth()) {
        ROUND_NUMBER++;
        IS_NEW_ROUND = true;
    } else {
        IS_NEW_ROUND = false;
    }
}

double Antenna::getDAzimuth() {
    return (double) getRPS()/PRF * 2*M_PI;
}

